home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Prog
/
M
/
MacStarter.cpt
/
main.c
< prev
next >
Wrap
Text File
|
1992-10-10
|
4KB
|
136 lines
/* MacStarter is a shell for simple Macintosh applications shell written in
THINK C, with some small use of its object-oriented features.
The whole system is described in a README file that should be in
the same folder with this file.
You can completely ignore this file, whose job is simply to handle
the basic interaction with the user and to route "events" to their
proper handlers.
*/
#include "globals-MacStarter.h"
MenuHandle appleMenu;
Handle gMenuBar;
void HandleMenuEvent(long selection, int* done);
void InstallMenus(void);
void InitApplication(void);
void UpdateMenus(void);
void DoEditMenu(int itemNum);
void DoFileMenu(int itemNum, int* done);
void DoOtherMenu(int menuID, int itemNum);
void ApplicationIdle(void);
void CleanUpApplication(void);
void AboutBox(void);
void main (void) {
int done;
xWindow *win;
short partNum;
long select;
WindowPtr clickWin;
InitGraf(&thePort);
InitFonts();
FlushEvents(everyEvent, 0);
InitWindows();
InitMenus();
TEInit();
InitDialogs(0L);
MaxApplZone();
InstallMenus();
InitApplication();
InitCursor();
done = 0;
for (;!done;) {
if (WaitNextEvent(everyEvent,&gEvent,gEventWaitTime,0L))
switch (gEvent.what) {
case keyDown: {
if (gEvent.modifiers & cmdKey) {
UpdateMenus();
if (select = MenuKey(gEvent.message & 0xFF))
HandleMenuEvent(select, &done);
}
else {
if (xWindow::Window2XWindow(FrontWindow(),&win))
win->doEvent();
};
break;
};
case autoKey: {
if (!(gEvent.modifiers & cmdKey)) {
if (xWindow::Window2XWindow(FrontWindow(),&win))
win->doEvent();
};
break;
};
case mouseDown: {
partNum = FindWindow(gEvent.where,&clickWin);
if (partNum == inMenuBar) {
UpdateMenus();
if (select = MenuSelect(gEvent.where))
HandleMenuEvent(select, &done);
}
else if (partNum == inSysWindow) {
SystemClick(&gEvent,clickWin);
}
else if (partNum >= inContent) {
if (xWindow::Window2XWindow(clickWin,&win))
win->doEvent();
};
break;
}
case updateEvt: {
if (xWindow::Window2XWindow((WindowPtr)gEvent.message,&win))
win->doEvent();
break;
}
case activateEvt: {
if (xWindow::Window2XWindow((WindowPtr)gEvent.message,&win))
win->doEvent();
}
};
ApplicationIdle();
};
CleanUpApplication();
}
void HandleMenuEvent(long selection, int* done) {
short menuID, itemNum;
Str255 daName;
menuID = HiWord(selection);
itemNum = LoWord(selection);
if (menuID) {
if (menuID == 1) {
if (itemNum == 1)
AboutBox();
else {
GetItem(appleMenu,itemNum,&daName);
OpenDeskAcc(daName);
}
}
else if (menuID == 2) {
DoFileMenu(itemNum,done);
}
else if (menuID == 3) {
if ( itemNum == 2 || itemNum > 6 || !(SystemEdit(itemNum-1)) )
DoEditMenu(itemNum);
};
HiliteMenu(0);
}
}
void InstallMenus(void) {
gMenuBar = GetNewMBar(1024);
SetMenuBar(gMenuBar);
appleMenu = GetMHandle(1);
AddResMenu(appleMenu, 'DRVR');
DrawMenuBar();
}